package de.koller.aframe.gl;

import de.koller.aframe.gl.ATexture.ITextureBuilder;
import de.koller.oceanFramework.gl.util.ParticleTexture;
import de.koller.oceanFramework.gl.util.RasterManager;
import de.koller.oceanFramework.gl.util.TextureUtil;
import org.lwjgl.opengl.GL11;

public class BitmapTexture extends ATexture implements ITextureBuilder {

	private RasterManager image;

	public BitmapTexture( String file ) {
		super();
		image = TextureUtil.load( file );
	}
	
	@Override
	protected void setUp( TextureParameters tparam ) {
		tparam.magFilter = GL11.GL_LINEAR;
		tparam.size = image.getWidth();
		tparam.builder = this;
	}

	@Override
	public void build( ParticleTexture texture ) {
		System.arraycopy( image.getData(), 0, texture.getData(), 0, image.getData().length );
	}
	
	public float tcoord( int pixel ) {
		float k = 1f / image.getWidth();
		return (float)pixel * k;
	}
	
}
